package com.handinfo.game;

import java.io.DataInputStream;
import java.io.IOException;
import javax.microedition.lcdui.Graphics;

import com.handinfo.engine.AbstractGameScreen;
import com.handinfo.uimenu.UIManager;
import com.handinfo.uimenu.UIPalette;
import com.handinfo.util.Tools;

public class Task
{
	public String m_name = null;// 名字
	public String m_key = null;// key
	public byte m_status = 0;// 状态
	public byte m_type = 0;// 类型
	public int m_lv = 0;// 等级
	public byte m_difficulty = 0;// 难度等级
	public String m_depict = null;// 描述
	public String m_pathfinding_tip = null;//寻路提示
	public String m_npc_key = null;//关联NPC的KEY
	public int m_exp = 0;// 奖励经验
	public long m_money = 0;// 奖励金钱数量

	public byte m_detail_size = 0;// 详细信息显示的长度

	public String[] m_propID = null;// 奖励道具ID
	public int[] m_propCount = null;// 奖励道具数量

	public String[] m_renownID = null;// 奖励声望ID
	public int[] m_renownCount = null;// 奖励声望数量

	public String m_progress = null;// 任务进度信息
	public String m_tooltip = null;// 任务提示

	public boolean m_show_detail = false;// 是否显示详细信息

	public final String[] TASK_STATUS = { "[未接]", "[未完成]", "[完成]" };
	public final int[] TASK_NAME_COLOR = {0xF8EC89, 0xE73F3F, 0x2CB81E, 0xAEAEAE};
	public final String[] TASK_NAME_COLOR_STR = {"F8EC89", "E73F3F", "2CB81E", "AEAEAE"};

	public Task()
	{
		
	}
	
	public void drawContent(Graphics g, int x, int y)
	{
		g.setColor(UIManager.getPaletteColor(UIPalette.COLOR_WORD_NOS));
		g.drawString(m_name, x, y, Tools.LEFT_TOP);
		g.setColor(TASK_NAME_COLOR[m_status]);
		g.drawString(TASK_STATUS[m_status], x + AbstractGameScreen.s_font.stringWidth(m_name) + 3, y, Tools.LEFT_TOP);
	}

	/**
	 * 读取一个任务
	 * @param dis
	 * @param task
	 * @throws IOException
	 */
	public void readTask(DataInputStream dis, byte type) throws IOException
	{
		m_name = dis.readUTF();
		m_key = dis.readUTF();
		m_status = dis.readByte();
		m_lv = dis.readInt();
		m_type = type;
		m_difficulty = dis.readByte();
	}
	/**
	 * 读取一个任务
	 * @param dis
	 * @param task
	 * @throws IOException
	 */
	public void readTaskByKey(DataInputStream dis, byte type) throws IOException
	{
		m_name = dis.readUTF();
		m_key = dis.readUTF();
		m_status = dis.readByte();
		m_lv = dis.readInt();
		m_type = type;
		m_difficulty = dis.readByte();
		m_npc_key = dis.readUTF();
	}
//	public Containner getContainner()
//	{
//		ComponentRoot root = new ComponentRoot((short) -1);
//		root.setWH(180, Component.HEIGHT_ITEM);
//		ComponentLeaf leaf = null;
//		leaf = ComponentLeaf.createStrLeaf(0, 0, m_name);
//		root.addComponent(leaf);
//		ContainnerComp comp = Component.createContainnerByComponent(root);
//		return comp;
//	}
}
